package org.thava.fortune;

import java.io.IOException;

import org.thava.fortune.utils.FortuneReader;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.TextView;

public class FortuneAndroidActivity extends Activity {
    /** Called when the activity is first created. */
	FortuneReader r;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
			r = new FortuneReader(this);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        TextView tv = new TextView(this);
        Resources res = getResources();
        Drawable d = res.getDrawable(R.drawable.background);
//        tv.setBackgroundDrawable(d);
        tv.setBackgroundColor(Color.BLUE);
        tv.setTextColor(Color.BLACK);
        tv.setText(r.getaFortune());
        setContentView(tv);
        tv.setOnClickListener(new OnClickListener() {
        	public void onItemClick(AdapterView parent, View view,int position, long id) {

        	}

			public void onClick(View arg0) {
				((TextView) arg0).setText(r.getaFortune());
				
			}
    });
}}